<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\vis\order\jit\service\order;

class JitOrderDetailAndPrice {
	
	static $_TSPEC;
	public $order_sn = null;
	public $add_time = null;
	public $stat = null;
	public $good_sn = null;
	public $amount = null;
	public $po = null;
	public $pick_no = null;
	public $vip_delivery_no = null;
	public $update_time = null;
	public $delivery_kpi_start_time = null;
	public $shelf_num = null;
	public $is_split_order = null;
	public $old_order_sn = null;
	public $is_prebuy = null;
	public $tax_rate = null;
	public $gross_margin_rate = null;
	public $bill_price = null;
	public $bill_tax_price = null;
	public $active_order_price = null;
	public $sum_vendor_fav_price = null;
	public $sum_fav_price = null;
	public $original_price = null;
	public $active_new_rule_flag = null;
	public $cooperation_type = null;
	public $discount_detail = null;
	public $new_order_list = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'order_sn'
			),
			2 => array(
			'var' => 'add_time'
			),
			3 => array(
			'var' => 'stat'
			),
			4 => array(
			'var' => 'good_sn'
			),
			5 => array(
			'var' => 'amount'
			),
			6 => array(
			'var' => 'po'
			),
			7 => array(
			'var' => 'pick_no'
			),
			8 => array(
			'var' => 'vip_delivery_no'
			),
			9 => array(
			'var' => 'update_time'
			),
			10 => array(
			'var' => 'delivery_kpi_start_time'
			),
			11 => array(
			'var' => 'shelf_num'
			),
			12 => array(
			'var' => 'is_split_order'
			),
			13 => array(
			'var' => 'old_order_sn'
			),
			14 => array(
			'var' => 'is_prebuy'
			),
			40 => array(
			'var' => 'tax_rate'
			),
			41 => array(
			'var' => 'gross_margin_rate'
			),
			42 => array(
			'var' => 'bill_price'
			),
			43 => array(
			'var' => 'bill_tax_price'
			),
			44 => array(
			'var' => 'active_order_price'
			),
			45 => array(
			'var' => 'sum_vendor_fav_price'
			),
			46 => array(
			'var' => 'sum_fav_price'
			),
			47 => array(
			'var' => 'original_price'
			),
			48 => array(
			'var' => 'active_new_rule_flag'
			),
			49 => array(
			'var' => 'cooperation_type'
			),
			50 => array(
			'var' => 'discount_detail'
			),
			51 => array(
			'var' => 'new_order_list'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['order_sn'])){
				
				$this->order_sn = $vals['order_sn'];
			}
			
			
			if (isset($vals['add_time'])){
				
				$this->add_time = $vals['add_time'];
			}
			
			
			if (isset($vals['stat'])){
				
				$this->stat = $vals['stat'];
			}
			
			
			if (isset($vals['good_sn'])){
				
				$this->good_sn = $vals['good_sn'];
			}
			
			
			if (isset($vals['amount'])){
				
				$this->amount = $vals['amount'];
			}
			
			
			if (isset($vals['po'])){
				
				$this->po = $vals['po'];
			}
			
			
			if (isset($vals['pick_no'])){
				
				$this->pick_no = $vals['pick_no'];
			}
			
			
			if (isset($vals['vip_delivery_no'])){
				
				$this->vip_delivery_no = $vals['vip_delivery_no'];
			}
			
			
			if (isset($vals['update_time'])){
				
				$this->update_time = $vals['update_time'];
			}
			
			
			if (isset($vals['delivery_kpi_start_time'])){
				
				$this->delivery_kpi_start_time = $vals['delivery_kpi_start_time'];
			}
			
			
			if (isset($vals['shelf_num'])){
				
				$this->shelf_num = $vals['shelf_num'];
			}
			
			
			if (isset($vals['is_split_order'])){
				
				$this->is_split_order = $vals['is_split_order'];
			}
			
			
			if (isset($vals['old_order_sn'])){
				
				$this->old_order_sn = $vals['old_order_sn'];
			}
			
			
			if (isset($vals['is_prebuy'])){
				
				$this->is_prebuy = $vals['is_prebuy'];
			}
			
			
			if (isset($vals['tax_rate'])){
				
				$this->tax_rate = $vals['tax_rate'];
			}
			
			
			if (isset($vals['gross_margin_rate'])){
				
				$this->gross_margin_rate = $vals['gross_margin_rate'];
			}
			
			
			if (isset($vals['bill_price'])){
				
				$this->bill_price = $vals['bill_price'];
			}
			
			
			if (isset($vals['bill_tax_price'])){
				
				$this->bill_tax_price = $vals['bill_tax_price'];
			}
			
			
			if (isset($vals['active_order_price'])){
				
				$this->active_order_price = $vals['active_order_price'];
			}
			
			
			if (isset($vals['sum_vendor_fav_price'])){
				
				$this->sum_vendor_fav_price = $vals['sum_vendor_fav_price'];
			}
			
			
			if (isset($vals['sum_fav_price'])){
				
				$this->sum_fav_price = $vals['sum_fav_price'];
			}
			
			
			if (isset($vals['original_price'])){
				
				$this->original_price = $vals['original_price'];
			}
			
			
			if (isset($vals['active_new_rule_flag'])){
				
				$this->active_new_rule_flag = $vals['active_new_rule_flag'];
			}
			
			
			if (isset($vals['cooperation_type'])){
				
				$this->cooperation_type = $vals['cooperation_type'];
			}
			
			
			if (isset($vals['discount_detail'])){
				
				$this->discount_detail = $vals['discount_detail'];
			}
			
			
			if (isset($vals['new_order_list'])){
				
				$this->new_order_list = $vals['new_order_list'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'JitOrderDetailAndPrice';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("order_sn" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->order_sn);
				
			}
			
			
			
			
			if ("add_time" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->add_time);
				
			}
			
			
			
			
			if ("stat" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->stat);
				
			}
			
			
			
			
			if ("good_sn" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->good_sn);
				
			}
			
			
			
			
			if ("amount" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->amount); 
				
			}
			
			
			
			
			if ("po" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->po);
				
			}
			
			
			
			
			if ("pick_no" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->pick_no);
				
			}
			
			
			
			
			if ("vip_delivery_no" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->vip_delivery_no);
				
			}
			
			
			
			
			if ("update_time" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->update_time);
				
			}
			
			
			
			
			if ("delivery_kpi_start_time" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->delivery_kpi_start_time);
				
			}
			
			
			
			
			if ("shelf_num" == $schemeField){
				
				$needSkip = false;
				$input->readI32($this->shelf_num); 
				
			}
			
			
			
			
			if ("is_split_order" == $schemeField){
				
				$needSkip = false;
				$input->readByte($this->is_split_order); 
				
			}
			
			
			
			
			if ("old_order_sn" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->old_order_sn);
				
			}
			
			
			
			
			if ("is_prebuy" == $schemeField){
				
				$needSkip = false;
				$input->readByte($this->is_prebuy); 
				
			}
			
			
			
			
			if ("tax_rate" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->tax_rate);
				
			}
			
			
			
			
			if ("gross_margin_rate" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->gross_margin_rate);
				
			}
			
			
			
			
			if ("bill_price" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->bill_price);
				
			}
			
			
			
			
			if ("bill_tax_price" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->bill_tax_price);
				
			}
			
			
			
			
			if ("active_order_price" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->active_order_price);
				
			}
			
			
			
			
			if ("sum_vendor_fav_price" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->sum_vendor_fav_price);
				
			}
			
			
			
			
			if ("sum_fav_price" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->sum_fav_price);
				
			}
			
			
			
			
			if ("original_price" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->original_price);
				
			}
			
			
			
			
			if ("active_new_rule_flag" == $schemeField){
				
				$needSkip = false;
				$input->readString($this->active_new_rule_flag);
				
			}
			
			
			
			
			if ("cooperation_type" == $schemeField){
				
				$needSkip = false;
				$input->readByte($this->cooperation_type); 
				
			}
			
			
			
			
			if ("discount_detail" == $schemeField){
				
				$needSkip = false;
				
				$this->discount_detail = array();
				$_size0 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem0 = null;
						
						$elem0 = new \com\vip\vis\order\jit\service\order\DiscountDetail();
						$elem0->read($input);
						
						$this->discount_detail[$_size0++] = $elem0;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			
			if ("new_order_list" == $schemeField){
				
				$needSkip = false;
				
				$this->new_order_list = array();
				$_size1 = 0;
				$input->readListBegin();
				while(true){
					
					try{
						
						$elem1 = null;
						
						$elem1 = new \com\vip\vis\order\jit\service\order\SplitNewOrder();
						$elem1->read($input);
						
						$this->new_order_list[$_size1++] = $elem1;
					}
					catch(\Exception $e){
						
						break;
					}
				}
				
				$input->readListEnd();
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		if($this->order_sn !== null) {
			
			$xfer += $output->writeFieldBegin('order_sn');
			$xfer += $output->writeString($this->order_sn);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->add_time !== null) {
			
			$xfer += $output->writeFieldBegin('add_time');
			$xfer += $output->writeString($this->add_time);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->stat !== null) {
			
			$xfer += $output->writeFieldBegin('stat');
			$xfer += $output->writeString($this->stat);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->good_sn !== null) {
			
			$xfer += $output->writeFieldBegin('good_sn');
			$xfer += $output->writeString($this->good_sn);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->amount !== null) {
			
			$xfer += $output->writeFieldBegin('amount');
			$xfer += $output->writeI32($this->amount);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->po !== null) {
			
			$xfer += $output->writeFieldBegin('po');
			$xfer += $output->writeString($this->po);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->pick_no !== null) {
			
			$xfer += $output->writeFieldBegin('pick_no');
			$xfer += $output->writeString($this->pick_no);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->vip_delivery_no !== null) {
			
			$xfer += $output->writeFieldBegin('vip_delivery_no');
			$xfer += $output->writeString($this->vip_delivery_no);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->update_time !== null) {
			
			$xfer += $output->writeFieldBegin('update_time');
			$xfer += $output->writeString($this->update_time);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->delivery_kpi_start_time !== null) {
			
			$xfer += $output->writeFieldBegin('delivery_kpi_start_time');
			$xfer += $output->writeString($this->delivery_kpi_start_time);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->shelf_num !== null) {
			
			$xfer += $output->writeFieldBegin('shelf_num');
			$xfer += $output->writeI32($this->shelf_num);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->is_split_order !== null) {
			
			$xfer += $output->writeFieldBegin('is_split_order');
			$xfer += $output->writeByte($this->is_split_order);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->old_order_sn !== null) {
			
			$xfer += $output->writeFieldBegin('old_order_sn');
			$xfer += $output->writeString($this->old_order_sn);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->is_prebuy !== null) {
			
			$xfer += $output->writeFieldBegin('is_prebuy');
			$xfer += $output->writeByte($this->is_prebuy);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->tax_rate !== null) {
			
			$xfer += $output->writeFieldBegin('tax_rate');
			$xfer += $output->writeString($this->tax_rate);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->gross_margin_rate !== null) {
			
			$xfer += $output->writeFieldBegin('gross_margin_rate');
			$xfer += $output->writeString($this->gross_margin_rate);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->bill_price !== null) {
			
			$xfer += $output->writeFieldBegin('bill_price');
			$xfer += $output->writeString($this->bill_price);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->bill_tax_price !== null) {
			
			$xfer += $output->writeFieldBegin('bill_tax_price');
			$xfer += $output->writeString($this->bill_tax_price);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->active_order_price !== null) {
			
			$xfer += $output->writeFieldBegin('active_order_price');
			$xfer += $output->writeString($this->active_order_price);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->sum_vendor_fav_price !== null) {
			
			$xfer += $output->writeFieldBegin('sum_vendor_fav_price');
			$xfer += $output->writeString($this->sum_vendor_fav_price);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->sum_fav_price !== null) {
			
			$xfer += $output->writeFieldBegin('sum_fav_price');
			$xfer += $output->writeString($this->sum_fav_price);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->original_price !== null) {
			
			$xfer += $output->writeFieldBegin('original_price');
			$xfer += $output->writeString($this->original_price);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->active_new_rule_flag !== null) {
			
			$xfer += $output->writeFieldBegin('active_new_rule_flag');
			$xfer += $output->writeString($this->active_new_rule_flag);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->cooperation_type !== null) {
			
			$xfer += $output->writeFieldBegin('cooperation_type');
			$xfer += $output->writeByte($this->cooperation_type);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->discount_detail !== null) {
			
			$xfer += $output->writeFieldBegin('discount_detail');
			
			if (!is_array($this->discount_detail)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->discount_detail as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->new_order_list !== null) {
			
			$xfer += $output->writeFieldBegin('new_order_list');
			
			if (!is_array($this->new_order_list)){
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$output->writeListBegin();
			foreach ($this->new_order_list as $iter0){
				
				
				if (!is_object($iter0)) {
					
					throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
				}
				
				$xfer += $iter0->write($output);
				
			}
			
			$output->writeListEnd();
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>